#include<stdio.h>
int main()
{
    int k,x;
    scanf("%d%d",&k,&x);
    int count = 0;
    for(int i =1;i<=k;i++)
    {
        int b = i;
        while(b)
        {
            if(b%10==x)
            {
                count++;
            }
            b/=10;
        }
    }
    printf("%d",count);
    return 0;
}